/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |				
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  8                                   	
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     pisoFoam;

//startFrom       startTime;
startFrom       latestTime;

startTime       0;

stopAt          endTime;

endTime         400;

//deltaT          0.0001;
//deltaT          0.0005;
//deltaT          0.0010;
deltaT          0.0015;
//deltaT          0.0020;
//deltaT          0.0025;
//deltaT          0.0030;

writeControl    adjustableRunTime;
/*
adjustableRunTime
clockTime
cpuTime
runTime
timeStep
*/

writeInterval   0.25;

/*
secondaryWriteControl    cpuTime;
secondaryWriteInterval   1000; 
secondaryPurgeWrite      1; 
*/

purgeWrite      0;

writeFormat     ascii;

writePrecision  8;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable yes;

//Not implemented in PISO
/*
adjustTimeStep  yes;
maxCo           0.6;
maxDeltaT       0.1;
*/

// ************************************************************************* //

functions
{

///////////////////////////////////////////////////////////////////////////
    inMassFlow
    {
        type            surfaceFieldValue;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         false;

//        writeControl     outputTime;
	writeControl   timeStep;
	writeInterval  1;

        log             true;

        writeFields     false;

        regionType          patch;
        name      in;

	operation       sum;
        fields
        (
            phi
        );
    }
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
    outMassFlow
    {
        type            surfaceFieldValue;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         false;

//      writeControl     outputTime;

	writeControl   timeStep;
	writeInterval  1;

        log             yes;

        writeFields     false;

        //writeFields     true;
        //surfaceFormat   raw;

        regionType          patch;
        name      out;

	operation       sum;
        fields
        (
            phi
        );
    }
///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

    fieldAverage
    {
        type            fieldAverage;
        functionObjectLibs ("libfieldFunctionObjects.so");
        enabled         false;
        writeControl   outputTime;

//writeControl   timeStep;
//writeInterval  100;

//cleanRestart true;

/*
        timeStart       20;
        timeEnd         200;
*/

        fields
        (
            U
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }

            p
            {
                mean        on;
                prime2Mean  on;
                base        time;
            }
        );
    }

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

forceCoeffs_object
{
	// rhoInf - reference density
	// CofR - Centre of rotation
	// dragDir - Direction of drag coefficient
	// liftDir - Direction of lift coefficient
	// pitchAxis - Pitching moment axis
	// magUinf - free stream velocity magnitude
	// lRef - reference length
	// Aref - reference area
	type forceCoeffs;
	functionObjectLibs ("libforces.so");
	//patches ("body1" "body2" "body3");
	patches ("cylinder");

	pName p;
	Uname U;
	rho rhoInf;
	rhoInf 1.0;

	//// Dump to file
	log true;

	CofR (0.0 0 0);
	liftDir (0 1 0);
	dragDir (1 0 0);
	pitchAxis (0 0 1);
	magUInf 1.0;
	lRef 1.0;         // reference lenght
	Aref 2.0;         // reference area 1 for 2d

        writeControl   timeStep;
        writeInterval  1;
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////

minmaxdomain
{
	type fieldMinMax;
	//type banana;

	functionObjectLibs ("libfieldFunctionObjects.so");

	enabled true;

	mode component;

	writeControl timeStep;
	writeInterval 1;

	log true;

	fields (p U nuSgs);
}

///////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////
fileUpdate1
{
	type timeActivatedFileUpdate;
	functionObjectLibs ("libutilityFunctionObjects.so");

	writeControl timeStep;
	writeInterval 1;

	fileToUpdate "$FOAM_CASE/system/controlDict";

	timeVsFile
	(
		( -1   "$FOAM_CASE/system/controlDict.0")		//dt 0.0001 read in at time 0 
		(0.1   "$FOAM_CASE/system/controlDict.1")		//dt 0.0005
		(0.2   "$FOAM_CASE/system/controlDict.2")		//dt 0.0010
		(0.5   "$FOAM_CASE/system/controlDict.3")		//dt 0.0015
		(1.0   "$FOAM_CASE/system/controlDict.4")		//dt 0.0020
		(2.0   "$FOAM_CASE/system/controlDict.5")		//dt 0.0025
		(3.0   "$FOAM_CASE/system/controlDict.6")		//dt 0.0030
	);
}
///////////////////////////////////////////////////////////////////////////

};
